package com.itheima.dao;



import com.github.pagehelper.Page;
import com.itheima.domain.Menu_management;
import com.itheima.domain.Role_management;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface Role_managementDao {

    @Select("select * from t_role")
    List<Role_management> findAll();
    @Select("select * from t_role where id = #{userId}")
    Role_management findById(Integer userId);
    @Update({"update user set id=#{id},name=#{name},keyword=#{keyword},description=#{description}"})
    void updateRole(Role_management role);
    @Insert("insert into t_role values(null,#{name},#{keyword},#{description})")
    void save(Role_management role_management);
    @Delete("delete from t_role where id = #{id}")
    void deleteById(Integer id);
    @Update({"update `t_role`  set name=#{name},keyword=#{keyword},description=#{description} where id=#{id}"})
    void edit(Role_management role_management);

    Page<Role_management> selectByCondition(String queryString);
    @Select("<script>" +
            "select * from t_role\n" +
            "<if test=\"value != null and value.length > 0\">\n" +
            "where code like concat(concat('%',#{value}),'%') or name like concat(concat('%',#{value}),'%') or id like concat(concat('%',#{value}),'%')\n" +
            "</if>" +
            "</script>")
    List<Role_management> EstimateFindAll();
}

